<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class Custom_Form extends Zend_Form {

    public function __construct($options = null) {
        #element decorator
        $this->setElementDecorators(array(
            'ViewHelper',
            array('Description', array('tag' => 'p', 'class' => 'desc')),
            array('Callback', array('callback' => array('Custom_Form','callbackInsertTag'), 'placement' => 'prepend',)),
            'Errors',
            array('Label', array('requiredSuffix' => '<span style="color:#FF0000;"> *</span>', 'escape' => false)),
            array('HtmlTag', array('tag' => 'p', 'class' => 'element')),
        ));

        parent::__construct($options);
    }

    public function loadDefaultDecorators() {
        if ($this->loadDefaultDecoratorsIsDisabled()) {
            return;
        }

        $this->setDecorators(array(
            'FormElements',
            'Description',
            array('HtmlTag', array('tag' => 'p', 'class' => 'main-frm')),
            'Form'
        ));
    }

    public function setCustomFileDecorators() {
        return array('File',
            array('Callback', array('callback' => array('Custom_Form','callbackInsertTag'), 'placement' => 'prepend',)),
            'Errors',
            'Label',
            array('HtmlTag', array('tag' => 'p', 'class' => 'element')),
        );
    }

    public function loadFormClass($class = 'small-frm', $tag = 'div') {
        $this->setDisableLoadDefaultDecorators(true);
        $this->setDecorators(array(
            'FormElements',
            'Description',
            array('HtmlTag', array('tag' => $tag, 'class' => $class)),
            'Form'
        ));
    }

    public static function callbackInsertTag($content, $element, array $options)
    {
         return (get_class($element) != "Zend_Form_Element_Submit") ? '<br />' : '';
    }

}

?>
